package com.hengpeng.itfin.persist.impl;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.hengpeng.common.persist.AbstractDao;
import com.hengpeng.common.persist.query.DynamicQuery;
import com.hengpeng.itfin.persist.PaymentDao;
import com.hengpeng.itfinbase.persist.Payment;
import com.hengpeng.itfinbase.persist.Payment.PayStatus;
import com.hengpeng.itfinbase.persist.Payment.PaymentType;

@Repository
public class PaymentDaoImpl extends AbstractDao<Payment> implements PaymentDao {
    @Override
    public int updateStatus(PayStatus oldStatus, PayStatus newStatus, Date updateTime, Date overTime, Long chargemoney,
            Long id) {
        return super.exeNamedQuery("payment.updateStatus", new Object[] { newStatus, updateTime, overTime, chargemoney,
                id, oldStatus });
    }

    @Override
    public List<Payment> queryList(PaymentType type, PayStatus status) {
        DynamicQuery query = new DynamicQuery(Payment.class);
        if (type != null) {
            query.eq("type", type);
        }
        if (status != null) {
            query.eq("status", status);
        }
        return super.findAllByDynamicQuery(query, Payment.class);
    }

}
